import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductCategoryVO, ProductCategoryForm, ProductCategoryQuery } from '@/api/logic/productCategory/types';

/**
 * 查询产品分了管理列表
 * @param query
 * @returns {*}
 */

export const listProductCategory = (query?: ProductCategoryQuery): AxiosPromise<ProductCategoryVO[]> => {
  return request({
    url: '/logic/productCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品分了管理详细
 * @param categoryId
 */
export const getProductCategory = (categoryId: string | number): AxiosPromise<ProductCategoryVO> => {
  return request({
    url: '/logic/productCategory/' + categoryId,
    method: 'get'
  });
};

/**
 * 新增产品分了管理
 * @param data
 */
export const addProductCategory = (data: ProductCategoryForm) => {
  return request({
    url: '/logic/productCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品分了管理
 * @param data
 */
export const updateProductCategory = (data: ProductCategoryForm) => {
  return request({
    url: '/logic/productCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品分了管理
 * @param categoryId
 */
export const delProductCategory = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/logic/productCategory/' + categoryId,
    method: 'delete'
  });
};

// 修改产品分类状态
export const changeStatus = (data) => {
  return request({
    url: '/logic/productCategory/changeStatus',
    method: 'put',
    data
  });
};
